﻿
var keyValue = request('keyValue');
var parentId = request('parentId');
var acceptClick;
var bootstrap = function ($, learun) {
    "use strict";
    var Extension = "";
    var page = {
        init: function () {
            page.initControl();
        },
        //初始化控件
        initControl: function () {
            //获取表单
            if (!!keyValue) {
               $.lrSetForm(config.base_server() + 'filefolders/findById?id=' + keyValue, function (data) {//
                   $('#form').lrSetFormData(data);
               });
            } else {
               $("#parentId").val(parentId);
            }
        }
    };
    //保存表单
    acceptClick = function (callBack) {
        if (!$('#form').lrValidform()) {
            return false;
        }
        var postData = $("#form").lrGetFormData(keyValue);
        if (!!parentId) {
            postData["parentId"] = parentId;
        }
        console.log(postData);
            $.lrSaveForm(config.base_server() + 'filefolders/saveOrUpdate?access_token=' + config.getToken().access_token + '&keyValue=' + keyValue, JSON.stringify(postData), function (res) {
            // 保存成功后才回调
            if (!!callBack) {
                callBack();
            }
        });
    }
    page.init();
}


